package com.cskaoyan.controller;

import com.cskaoyan.bo.OrderRefundBo;
import com.cskaoyan.bo.OrderShipBo;
import com.cskaoyan.service.OrderService;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.vo.OrderDetailVo;
import com.cskaoyan.vo.OrderVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: libugu@cskaoyan.com
 * @date 2021/4/8 - 22:22
 */
@RestController
public class OrderController {

    @Autowired
    OrderService orderService;

    @RequestMapping("admin/order/list")
    public BaseRespVo list(Integer page, Integer limit, String sort, String order,Short orderStatusArray,Integer userId,Integer orderSn){

        OrderVo orderVo = orderService.query(page,limit,sort,order,orderStatusArray,userId,orderSn);
        return BaseRespVo.ok(orderVo);
    }
    @RequestMapping("admin/order/detail")
    public BaseRespVo detail(Integer id){

       OrderDetailVo orderDetailVo = orderService.getDetail(id);

       return BaseRespVo.ok(orderDetailVo);
    }

    @RequestMapping("admin/order/refund")
    public BaseRespVo refund(@RequestBody OrderRefundBo orderRefundBo){

       orderService.updateStatus(orderRefundBo);

       return BaseRespVo.ok();
    }

    @RequestMapping("admin/order/ship")
    public BaseRespVo ship(@RequestBody OrderShipBo orderShipBo){

        orderService.shipUpdateStatus(orderShipBo);

        return BaseRespVo.ok();
    }
}
